﻿package com.wandian.view.mediator
{
	import com.greensock.TweenLite;
	import com.wandian.controller.CLZNoticeName;

	import org.puremvc.as3.interfaces.*;
	import org.puremvc.as3.patterns.mediator.*;
	/**   
	* @author long
	* @QQ 108232706
	* @version 1.0   
	*/   
	public class DealerMediator extends Mediator
	{
		private var arrBanker:Array;
		public static const NAME:String="DealerMediator";

		public function DealerMediator(param1:Object=null)
		{
			super(NAME, param1);
			this.init();
			return;
		}

		private function init():void
		{
			this.arrBanker=[this.mDealer.banker1, this.mDealer.banker2, this.mDealer.banker3, this.mDealer.banker4, this.mDealer.banker5, this.mDealer.banker6, this.mDealer.banker7, this.mDealer.banker8, this.mDealer.banker9];
			var _loc_1:int=0;
			while (_loc_1 < this.arrBanker.length)
			{

				this.arrBanker[_loc_1].visible=false;
				_loc_1=_loc_1 + 1;
			}
			this.mDealer.banker.x=this.arrBanker[0].x;
			this.mDealer.banker.y=this.arrBanker[0].y;
			return;
		}

		private function showBanker(dealer:int):void
		{
			try
			{
				this.mDealer.banker.x=this.arrBanker[(dealer - 1)].x;
				this.mDealer.banker.y=this.arrBanker[(dealer - 1)].y;
			}
			catch (err:Error)
			{
			}
			return;
		}

		private function moveBanker(seatId:int):void
		{
			if (seatId > 0 && seatId < 10)
			{
				TweenLite.to(this.mDealer.banker, 1, {x: this.arrBanker[(seatId - 1)].x, y: this.arrBanker[(seatId - 1)].y});
				return;
			}
		}

		override public function onRegister():void
		{
			return;
		}

		override public function listNotificationInterests():Array
		{
			return [CLZNoticeName.INIT_DEALER_ID, CLZNoticeName.MOVE_DEALER];
		}

		override public function handleNotification(param1:INotification):void
		{
			switch (param1.getName())
			{
				case CLZNoticeName.INIT_DEALER_ID:
				{
					this.showBanker(param1.getBody() as int);
					break;
				}
				case CLZNoticeName.MOVE_DEALER:
				{
					this.moveBanker(param1.getBody() as int);
					break;
				}
				default:
				{
					break;
				}
			}
			return;
		}

		private function get mDealer():Object
		{
			return viewComponent;
		}

	}
}
